package com.loong.web.gp4j.view.manage;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.loong.web.gp4j.bean.schema.user.Auths;
import com.loong.web.gp4j.service.monitor.MonitorService;
import com.loong.web.suppert.collection.vo.ResultVo;
import com.loong.web.suppert.intercept.auth.AuthType;

/**
 * 监控视图资源
 *
 * @author 张成轩
 */
@Controller
@RequestMapping("manage/monitor")
public class MonitorViewMapping {

	@Resource
	private MonitorService monitorService;

	/**
	 * 监控页面
	 * 
	 * @param request 请求
	 * @return 视图
	 */
	@RequestMapping(value = "", method = RequestMethod.GET)
	@AuthType(Auths.SYS_MANAGER)
	public ModelAndView monitor(HttpServletRequest request) {

		return new ModelAndView("gp4j/manage/monitor");
	}

	/**
	 * 获取磁盘空间使用情况
	 * 
	 * @return 返回对象
	 */
	@RequestMapping(value = "space", method = RequestMethod.POST)
	@ResponseBody
	@AuthType(Auths.SYS_MANAGER)
	public ResultVo<?> space() {

		return monitorService.space();
	}

	/**
	 * 获取内存占用情况
	 * 
	 * @return 返回对象
	 */
	@RequestMapping(value = "memory", method = RequestMethod.POST)
	@ResponseBody
	@AuthType(Auths.SYS_MANAGER)
	public ResultVo<?> memory() {

		return monitorService.memory();
	}
}
